<%@ page import="java.sql.*" %>
<%@include file="../connection.jsp" %>

<%
            try {
                HttpSession ses = request.getSession(true);
                String ses_username = ses.getValue("ses_uname").toString();

                if (ses_username.equals("admin")) {

%>
<link href="../css/style.css" rel="stylesheet" />

<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    </tr>
    <tr>
        <td align="center"><strong><font size="4" face="Arial, Helvetica, sans-serif"><br />
                    Edit Info Investasi <br />
                </font></strong><br />      
        </td>
    </tr>
    <tr>
        <td>
            <%
                                String id = request.getParameter("id");
                                String sql = "SELECT * FROM t_artikel WHERE id = '" + id + "'";
                                rs = stmt.executeQuery(sql);

                                if (rs.next()) {
                                    String judul = rs.getString(2);
                                    String info = rs.getString(3);
            %>
            <form method="post" action="updateinfo.jsp" name="myForm" onsubmit="return(validate());">
                <table width="" border="1" align="center" cellpadding="3" cellspacing="0">
                    <tr>
                        <td width="">Judul</td>
                        <td width=""><input name="txtjudul" type="text" value="<% out.print(judul);%>" />
                            <input name="txtid" type="hidden" value="<% out.print(id);%>" /></td>
                    </tr>
                    <tr>
                        <td>Info</td>
                        <td><textarea name="txtinfo" cols="100" rows="10" value=""><% out.print(info);%></textarea></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><div align="right"><input type="submit" name="Submit" value="Simpan" /></div></td>
                    </tr>
                </table>
            </form>
            <%
                                }
                            }
                        } catch (Exception e) {
                            out.println("login Admin error");
                        }
            %>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
</table>
<script type="text/javascript">
    <!--
    // Form validation code will come here.
    function validate()
    {
 
        if( document.myForm.txtinfo.value == "" )
        {
            alert( "Info belum diisi!" );
            document.myForm.txtinfo.focus() ;
            return false;
        }
    }
</script>